package com.david.autostarter.logger.starter;


import com.david.autostarter.logger.annotation.Mylog;

import java.lang.reflect.Method;

import java.lang.reflect.Method;


public class DefaultLogSupport implements LogSupport {
    public Object invoke(Method method, Object[] args) {

        Mylog myLog = method.getAnnotation(Mylog.class);

        // 没有数据返回
        if (null == myLog) {
            return null;
        }

        String log = myLog.log();

        if (null != args && args.length == 1) {
            log += ":" + args[0];
        }

        System.out.println(log);

        if (method.getReturnType() == String.class || method.getReturnType() == Object.class) {
            return log;
        }

        return null;

    }
}